﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.IoC;
using Kooboo.Domain;

namespace Kooboo.Commerce.Domain.Services
{
    public class ProductQuestionService:ServiceBase<IProductQuestionRepository,IProductQuestion>
    {
        //internal ProductQuestionService()
        //{
        //}

        public override IQueryable<IProductQuestion> QueryService
        {
            get {
                return this.Repository.ProductQuestions;
            }
        }

  
        public void Post(IProductQuestion productQuestion)
        {
         
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(productQuestion);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(IProductQuestion productQuestion)
        {
           

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Put(productQuestion);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(IProductQuestion productQuestion)
        {
          
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(productQuestion);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }
    }

}
